This is a reorganization of how value computing should be done.
Previously the GtkCssStyleProperty.compute vfunc was supposed to take
care of special cases when it needed those for computation. However,
this proved to be very complicated in cases where values were nested and
only the last value (of a common type) needed to be special cased.
A common example for this was the fallback handling for unresolvable
colors.
Now, we pass the property's ID along with all compute functions so we
can do the special casing where it's necessary.
Note that no actual changes happen in this commit. This will happen in
follow-ups.
static GtkCssValue *
gtk_css_value_array_compute (GtkCssValue *value,
+ guint property_id,
GtkStyleContext *context)
{
GtkCssValue *result;
result = _gtk_css_array_value_new_from_array (value->values, value->n_values);
for (i = 0; i < value->n_values; i++)
{
- result->values[i] = _gtk_css_value_compute (value->values[i], context);
+ result->values[i] = _gtk_css_value_compute (value->values[i], property_id, context);
changed |= (result->values[i] != value->values[i]);
}
GtkCssValue *
gtk_css_value_bg_size_compute (GtkCssValue *value,
+ guint property_id,
GtkStyleContext *context)
{
if (value->x == NULL && value->y == NULL)
return _gtk_css_value_ref (value);
- return _gtk_css_bg_size_value_new (value->x ? _gtk_css_value_compute (value->x, context) : NULL,
- value->y ? _gtk_css_value_compute (value->y, context) : NULL);
+ return _gtk_css_bg_size_value_new (value->x ? _gtk_css_value_compute (value->x, property_id, context) : NULL,
+ value->y ? _gtk_css_value_compute (value->y, property_id, context) : NULL);
}
static gboolean
static GtkCssValue *
gtk_css_value_border_compute (GtkCssValue *value,
+ guint property_id,
GtkStyleContext *context)
{
GtkCssValue *computed;
{
if (value->values[i])
{
- computed->values[i] = _gtk_css_value_compute (value->values[i], context);
+ computed->values[i] = _gtk_css_value_compute (value->values[i], property_id, context);
changed |= (computed->values[i] != value->values[i]);
}
}
static GtkCssValue *
gtk_css_value_corner_compute (GtkCssValue *corner,
+ guint property_id,
GtkStyleContext *context)
{
GtkCssValue *x, *y;
- x = _gtk_css_value_compute (corner->x, context);
- y = _gtk_css_value_compute (corner->y, context);
+ x = _gtk_css_value_compute (corner->x, property_id, context);
+ y = _gtk_css_value_compute (corner->y, property_id, context);
if (x == corner->x && y == corner->y)
{
_gtk_css_value_unref (x);
static GtkCssValue *
gtk_css_value_ease_compute (GtkCssValue *value,
+ guint property_id,
GtkStyleContext *context)
{
return _gtk_css_value_ref (value);
static GtkCssValue *
gtk_css_value_engine_compute (GtkCssValue *value,
+ guint property_id,
GtkStyleContext *context)
{
return _gtk_css_value_ref (value);
static GtkCssValue *
gtk_css_value_enum_compute (GtkCssValue *value,
+ guint property_id,
GtkStyleContext *context)
{
return _gtk_css_value_ref (value);
static GtkCssImage *
gtk_css_image_real_compute (GtkCssImage *image,
+ guint property_id,
GtkStyleContext *context)
{
return g_object_ref (image);
GtkCssImage *
_gtk_css_image_compute (GtkCssImage *image,
+ guint property_id,
GtkStyleContext *context)
{
GtkCssImageClass *klass;
klass = GTK_CSS_IMAGE_GET_CLASS (image);
- return klass->compute (image, context);
+ return klass->compute (image, property_id, context);
}
void
static GtkCssImage *
gtk_css_image_gradient_compute (GtkCssImage *image,
+ guint property_id,
GtkStyleContext *context)
{
GtkCssImageGradient *gradient = GTK_CSS_IMAGE_GRADIENT (image);
static GtkCssImage *
gtk_css_image_linear_compute (GtkCssImage *image,
+ guint property_id,
GtkStyleContext *context)
{
static const GdkRGBA transparent = { 0, 0, 0, 0 };
copy = g_object_new (GTK_TYPE_CSS_IMAGE_LINEAR, NULL);
copy->repeating = linear->repeating;
- copy->angle = _gtk_css_value_compute (linear->angle, context);
+ copy->angle = _gtk_css_value_compute (linear->angle, property_id, context);
fallback = _gtk_css_symbolic_value_new_take_symbolic_color (gtk_symbolic_color_new_literal (&transparent));
g_array_set_size (copy->stops, linear->stops->len);
FALSE);
if (stop->offset)
- scopy->offset = _gtk_css_value_compute (stop->offset, context);
+ scopy->offset = _gtk_css_value_compute (stop->offset, property_id, context);
else
scopy->offset = NULL;
}
/* create "computed value" in CSS terms, returns a new reference */
GtkCssImage *(* compute) (GtkCssImage *image,
+ guint property_id,
GtkStyleContext *context);
/* draw to 0,0 with the given width and height */
double _gtk_css_image_get_aspect_ratio (GtkCssImage *image);
GtkCssImage * _gtk_css_image_compute (GtkCssImage *image,
+ guint property_id,
GtkStyleContext *context);
void _gtk_css_image_draw (GtkCssImage *image,
static GtkCssValue *
gtk_css_value_image_compute (GtkCssValue *value,
+ guint property_id,
GtkStyleContext *context)
{
GtkCssImage *image, *computed;
if (image == NULL)
return _gtk_css_value_ref (value);
- computed = _gtk_css_image_compute (image, context);
+ computed = _gtk_css_image_compute (image, property_id, context);
if (computed == image)
{
static GtkCssValue *
gtk_css_value_inherit_compute (GtkCssValue *value,
+ guint property_id,
GtkStyleContext *context)
{
/* This value should be caught further up */
static GtkCssValue *
gtk_css_value_initial_compute (GtkCssValue *value,
+ guint property_id,
GtkStyleContext *context)
{
/* This value should be caught further up */
static GtkCssValue *
gtk_css_value_number_compute (GtkCssValue *number,
+ guint property_id,
GtkStyleContext *context)
{
switch (number->unit)
static GtkCssValue *
gtk_css_value_position_compute (GtkCssValue *position,
+ guint property_id,
GtkStyleContext *context)
{
GtkCssValue *x, *y;
- x = _gtk_css_value_compute (position->x, context);
- y = _gtk_css_value_compute (position->y, context);
+ x = _gtk_css_value_compute (position->x, property_id, context);
+ y = _gtk_css_value_compute (position->y, property_id, context);
if (x == position->x && y == position->y)
{
_gtk_css_value_unref (x);
static GtkCssValue *
gtk_css_value_repeat_compute (GtkCssValue *value,
+ guint property_id,
GtkStyleContext *context)
{
return _gtk_css_value_ref (value);
static GtkCssValue *
gtk_css_value_rgba_compute (GtkCssValue *value,
+ guint property_id,
GtkStyleContext *context)
{
return _gtk_css_value_ref (value);
static GtkCssValue *
gtk_css_value_shadows_compute (GtkCssValue *value,
+ guint property_id,
GtkStyleContext *context)
{
GtkCssValue *result;
result = gtk_css_shadows_value_new (value->values, value->len);
for (i = 0; i < value->len; i++)
{
- result->values[i] = _gtk_css_value_compute (value->values[i], context);
+ result->values[i] = _gtk_css_value_compute (value->values[i], property_id, context);
}
return result;
static GtkCssValue *
gtk_css_value_shadow_compute (GtkCssValue *shadow,
+ guint property_id,
GtkStyleContext *context)
{
GdkRGBA transparent = { 0, 0, 0, 0 };
FALSE);
_gtk_css_value_unref (fallback);
- return gtk_css_shadow_value_new (_gtk_css_value_compute (shadow->hoffset, context),
- _gtk_css_value_compute (shadow->voffset, context),
- _gtk_css_value_compute (shadow->radius, context),
- _gtk_css_value_compute (shadow->spread, context),
+ return gtk_css_shadow_value_new (_gtk_css_value_compute (shadow->hoffset, property_id, context),
+ _gtk_css_value_compute (shadow->voffset, property_id, context),
+ _gtk_css_value_compute (shadow->radius, property_id, context),
+ _gtk_css_value_compute (shadow->spread, property_id, context),
shadow->inset,
color);
}
static GtkCssValue *
gtk_css_value_string_compute (GtkCssValue *value,
+ guint property_id,
GtkStyleContext *context)
{
return _gtk_css_value_ref (value);
GtkStyleContext *context,
GtkCssValue *specified)
{
- return _gtk_css_value_compute (specified, context);
+ return _gtk_css_value_compute (specified, _gtk_css_style_property_get_id (property), context);
}
static GtkCssValue *
GtkStyleContext *context,
GtkCssValue *specified)
{
- return _gtk_css_value_compute (specified, context);
+ return _gtk_css_value_compute (specified, _gtk_css_style_property_get_id (property), context);
}
static GtkCssValue *
GtkStyleContext *context,
GtkCssValue *specified)
{
- return _gtk_css_value_compute (specified, context);
+ return _gtk_css_value_compute (specified, _gtk_css_style_property_get_id (property), context);
}
static void
GtkStyleContext *context,
GtkCssValue *specified)
{
- return _gtk_css_value_compute (specified, context);
+ return _gtk_css_value_compute (specified, _gtk_css_style_property_get_id (property), context);
}
static void
GtkStyleContext *context,
GtkCssValue *specified)
{
- return _gtk_css_value_compute (specified, context);
+ return _gtk_css_value_compute (specified, _gtk_css_style_property_get_id (property), context);
}
static GtkCssValue *
GtkStyleContext *context,
GtkCssValue *specified)
{
- return _gtk_css_value_compute (specified, context);
+ return _gtk_css_value_compute (specified, _gtk_css_style_property_get_id (property), context);
}
static GtkCssValue *
GtkStyleContext *context,
GtkCssValue *specified)
{
- return _gtk_css_value_compute (specified, context);
+ return _gtk_css_value_compute (specified, _gtk_css_style_property_get_id (property), context);
}
static GtkCssValue *
GtkStyleContext *context,
GtkCssValue *specified)
{
- return _gtk_css_value_compute (specified, context);
+ return _gtk_css_value_compute (specified, _gtk_css_style_property_get_id (property), context);
}
static GtkCssValue *
GtkStyleContext *context,
GtkCssValue *specified)
{
- return _gtk_css_value_compute (specified, context);
+ return _gtk_css_value_compute (specified, _gtk_css_style_property_get_id (property), context);
}
static GtkCssValue *
border_style == GTK_BORDER_STYLE_HIDDEN)
return _gtk_css_number_value_new (0, GTK_CSS_PX);
else
- return _gtk_css_value_compute (specified, context);
+ return _gtk_css_value_compute (specified, _gtk_css_style_property_get_id (property), context);
}
static GtkCssValue *
GtkStyleContext *context,
GtkCssValue *specified)
{
- return _gtk_css_value_compute (specified, context);
+ return _gtk_css_value_compute (specified, _gtk_css_style_property_get_id (property), context);
}
static GtkCssValue *
GtkStyleContext *context,
GtkCssValue *specified)
{
- return _gtk_css_value_compute (specified, context);
+ return _gtk_css_value_compute (specified, _gtk_css_style_property_get_id (property), context);
}
/*** REGISTRATION ***/
static GtkCssValue *
gtk_css_value_typed_compute (GtkCssValue *value,
+ guint property_id,
GtkStyleContext *context)
{
return _gtk_css_value_ref (value);
GtkCssValue *
_gtk_css_value_compute (GtkCssValue *value,
+ guint property_id,
GtkStyleContext *context)
{
g_return_val_if_fail (value != NULL, NULL);
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
- return value->class->compute (value, context);
+ return value->class->compute (value, property_id, context);
}
gboolean
void (* free) (GtkCssValue *value);
GtkCssValue * (* compute) (GtkCssValue *value,
+ guint property_id,
GtkStyleContext *context);
gboolean (* equal) (const GtkCssValue *value1,
const GtkCssValue *value2);
void _gtk_css_value_unref (GtkCssValue *value);
GtkCssValue *_gtk_css_value_compute (GtkCssValue *value,
+ guint property_id,
GtkStyleContext *context);
gboolean _gtk_css_value_equal (const GtkCssValue *value1,
const GtkCssValue *value2);
static GtkCssValue *
gtk_css_value_symbolic_compute (GtkCssValue *value,
+ guint property_id,
GtkStyleContext *context)
{
/* for now we expect this to never be called